package mulMan.dao;

import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;

import mulMan.domain.Playlist;

public class PlaylistDAOImpl implements PlaylistDAO {

	private HibernateTemplate hibernateTemplate;
	public void setSessionFactory(SessionFactory sessionFactory){
		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
	}

	public void savePlaylist(Playlist playlist) {
		hibernateTemplate.save(playlist);
	}

	@SuppressWarnings("unchecked")
	public List<Playlist> getPlaylists() {
		return hibernateTemplate.find("from Playlist");
	}

	public Playlist getPlaylist(int idPlaylist) {
		return hibernateTemplate.get(Playlist.class, idPlaylist);
	}

	public void updatePlaylist(Playlist playlist) {
		hibernateTemplate.update(playlist);
	}

	public void deletePlaylist(Playlist playlist) {
		hibernateTemplate.delete(playlist);
	}

}
